/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Modele;

import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.TreeSet;

/**
 *
 * @author sio
 */
public class Pays {
    Collection<Dep> lesDeps;
    Collection<Specialite> lesSpe;
    
    public Pays(){
        lesDeps=DAO.getLesDeps();
        lesSpe=DAO.getLesSpe();
        
        for(Dep unDep : lesDeps){
            boolean find=false;
            for(Medecin unMed : unDep.getLesMedecins()){
                if(unMed.getSpe()!=null){
                    for(Specialite uneSpe : lesSpe){
                        if(unMed.getSpe().equals(uneSpe.getNom())){
                            uneSpe.addMed(unMed);
                            find=true;
                        }
                    }
                }
                
            }
        }
    }
    
    public Collection<Dep> getLesDeps(){
        return this.lesDeps;
    }
    
    public Collection<Specialite> getLesSpe(){
        return this.lesSpe;
    }
    
    public Dep getLeDep(String num){
        for(Dep unDep : lesDeps){
            if(unDep.getNum().equals(num)){
                return unDep;
            }              
        }
        return null;
    }
    
    public Specialite getLaSpe(String nom){
        for(Specialite uneSpe : lesSpe){
            if(uneSpe.getNom().equals(nom)){
                return uneSpe;
            }
        }
        return null;
    }
    
    public Collection<Medecin> getMedsByNom(String nom){
        Collection<Medecin> lesMeds = new TreeSet();
        for(Dep unDep : lesDeps) {
            for(Medecin unMed : unDep.getLesMedecins()){
                if(unMed.getNom().startsWith(nom)){
                    lesMeds.add(unMed);
                }
            }
        }
        return lesMeds;
    }


    
}
